<template>
  <div>
    <div class="container">
      <div>
        <el-form :model="formInline" ref="formInline" class="select-submit-form">
          <el-row type="flex">
            <el-col :span="8">
              <el-form-item label="大病赔案号" prop="caseNo">
                <el-input placeholder="请输入大病赔案号" v-model='formInline.caseNo'></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="被保险人" prop="insuredName">
                <el-input placeholder="请输入被保险人名称"  v-model='formInline.insuredName'></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="社/医保号" prop="socialSecurityNo">
                <el-input placeholder="请输入社/医保号"  v-model='formInline.socialSecurityNo'></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row type="flex">
            <el-col :span="8">
              <el-form-item label="任务状态" prop="taskState">
                <el-select placeholder="任务状态" v-model='formInline.taskState'>
                  <el-option label="待处理" value="01"></el-option>
                  <el-option label="已处理" value="03"></el-option>
                  <el-option label="已注销" value="05"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="证件号" prop="documentNo">
                <el-input v-model="formInline.documentNo"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="select-btn-group">
                <el-button type="primary" size="medium" @click="onSubmit">查询</el-button>
                <el-button type="primary" size="medium" @click="resetForm('formInline')">重置</el-button>
              </div>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <template>
        <div>
          <el-divider></el-divider>
        </div>
      </template>
      <el-table
        :data="tableData"
        class="table"
        ref="multipleTable"
        header-cell-class-name="table-header"
        v-loading="loading"
        element-loading-text="Loading..."
        style="margin: 30px 0;border: 1px solid #d6d9d8;"
      >
        <el-table-column type="index" label="序号" width="55" align="center"></el-table-column>
        <el-table-column prop="caseNo" label="大病赔案号" width="210px">
          <template  slot-scope="scope">
            <a href="#" style="color: #409EFF" @click="toCaseNo(scope.row)">{{scope.row.caseNo}}</a>
          </template>
        </el-table-column>
        <el-table-column prop="insuredName" label="被保险人名称" align="center"></el-table-column>
        <el-table-column prop="documentNo" label="证件号" width="220px" align="center"></el-table-column>
        <el-table-column prop="socialSecurityNo" label="社/医保号" width="220px" align="center"></el-table-column>
        <el-table-column prop="handleComrName" label="处理人机构" width="150" align="center"></el-table-column>
        <el-table-column prop="handlerName" label="处理人" align="center"></el-table-column>
        <el-table-column prop="flowInTime" label="流入时间" width="220px" align="center"></el-table-column>
        <el-table-column prop="serialNo" label="重开审核" align="center" width="50px">
          <template slot-scope="scope">
            <span v-if="scope.row.serialNo == '2'">是</span>
            <span v-else>否</span>
          </template>
        </el-table-column>
        <!-- <el-table-column prop="taskState" label="状态" align="center">
          <template slot-scope="scope">
            <el-button type="text" v-if="(scope.row.taskState)=='01'">待处理</el-button>
            <el-button type="text" v-if="(scope.row.taskState)=='02'">已暂存</el-button>
            <el-button type="text" v-if="(scope.row.taskState)=='03'">已处理</el-button>
            <el-button type="text" v-if="(scope.row.taskState)=='04'">已退回</el-button>
            <el-button type="text" v-if="(scope.row.taskState)=='05'">已关闭</el-button>
            <el-button type="text" v-if="(scope.row.taskState)=='06'">提交上级</el-button>
          </template>
        </el-table-column> -->
        <el-table-column prop="taskState" label="状态" :formatter="formatTaskState"  align="center"></el-table-column>
        <!-- <el-table-column label="操作" width="auto">
          <template slot-scope="scope">
            <el-button type="text" @click="toDetail1(scope.row)" v-if="(scope.row.taskState)=='01'">审核</el-button>
            <el-button type="text" @click="toDetail2(scope.row)" v-if="(scope.row.taskState)=='03'">查看</el-button>
          </template>
        </el-table-column> -->
      </el-table>
      <div style="margin-top: 15px">
        <template>
          <div class="pagination">
            <el-pagination v-show=" formInline.totalPage>0" :current-page="formInline.currentPage"
                           :page-sizes="[10, 25, 50, 100]"
                           :total="formInline.totalPage" background layout="prev, pager, next,sizes,total,jumper"
                           @current-change="queryFun"  @size-change="handleSizeChange">
            </el-pagination>
          </div>
        </template>
      </div>
    </div>
  </div>
</template>
<script>
  import * as api from '@/api/baseDate';
  import Cookies from "js-cookie";
  export default {
    name: 'caseClaimTaskCache',
    data() {
      return {
        loading: false,
        tableData: [],
        formInline: {
          caseNo: "",
          insuredName: "",
          socialSecurityNo: "",
          taskType: "undwrt",
          taskState: "",
          documentNo: "",
          pageNum: "1",//当前页码
          pageSize: "10",//每页条数
          totalPage: 0 // 总条数
        }
      };
    },
    created() {
    },
    methods: {
      toCaseNo(row){
        if(row.taskState == '01'){
          this.toDetail1(row)
        }else if(row.taskState == '03'){
          this.toDetail2(row)
        }
      },
      //查看跳转
      toDetail2(e) {
        this.$router.push({
        name: 'caseClaimTaskAudit',
          params: {
            caseNo: e.caseNo,
            taskId: e.taskId,
            taskType: e.taskType,
            policyNo: e.policyNo,
            damageDate: e.damageDate,
            taskState:e.taskState,
            name:"cache",
            serialNo:e.serialNo
            //任务类型
          }
        })
      },
      // 跳转明细页面
      toDetail1(e) {
        debugger
        console.log(Cookies)
        api.taskCheck({
          "processId": e.processId,
          "handleComrCode":Cookies.get("makeCom"),
          "handleComrName":Cookies.get("cMakeCom"),      
          "handlerCode":Cookies.get("userCode"),
          "handlerName":Cookies.get("userName"),
          "reqFlag": "check"
        }).then(res => {
           if(res.data.resultCode=="0000"){                 
            this.$router.push({
              name: 'caseClaimTaskAudit',
              params: {
                caseNo: e.caseNo,
                taskId: e.taskId,
                taskType: e.taskType,
                policyNo: e.policyNo,
                damageDate: e.damageDate,
                taskState:e.taskState,
                name:"cache",
                serialNo:e.serialNo,
                processId:e.processId
                //任务类型
              }
            })
           }else{
            this.$alert(res.data.resultMsg,'提示', {
                confirmButtonText: '确定'
              });
           }
        })          
      },
      //分页查询
      queryFun(pageNum) {
        this.formInline.pageNum = pageNum;
        this.onSubmit();
      },
      handleSizeChange(pageSize){ // 改变当前页条数事件
        this.formInline.pageSize = pageSize;
        this.onSubmit();
      },
      onSubmit() {
        this.loading = true;
        if (this.formInline.taskType == null || this.formInline.taskType == "" || this.formInline.taskType == undefined) {
          this.$message.warning(`请选择任务类型！`);
          return;
        }
        api.queryProcessEngineLists({
          "caseNo": this.formInline.caseNo,
          "insuredName": this.formInline.insuredName,
          "socialSecurityNo": this.formInline.socialSecurityNo,
          "taskType": this.formInline.taskType,
          "taskState": this.formInline.taskState,
          "documentNo": this.formInline.documentNo,
          "pageNum": this.formInline.pageNum,
          "pageSize": this.formInline.pageSize,
          "comCode":Cookies.get("makeCom"),
          "userCode":Cookies.get("userCode")

        }).then(res => {
          this.loading = false;
          this.tableData = res.data.list
          this.formInline.totalPage = res.data.total;
        })
      },
      //重置
      resetForm(formName) {
        debugger
        this.$refs[formName].resetFields();
      }
    }
  };
</script>
<style lang="scss" scoped></style>

